/**
  ******************************************************************************
  * @file    Project/STM32F10x_StdPeriph_Template/stm32f10x_it.c
  * @author  MCD Application Team
  * @version V3.5.0
  * @date    08-April-2011
  * @brief   Main Interrupt Service Routines.
  *          This file provides template for all exceptions handler and
  *          peripherals interrupt service routine.
  ******************************************************************************
  * @attention
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "app_error.h"



/** @addtogroup STM32F10x_StdPeriph_Template
  * @{
  */
/* Private define ------------------------------------------------------------*/

/* Private macro -------------------------------------------------------------*/


/* Private typedef -----------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/



/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/



/******************************************************************************/
/*          												                  */
/******************************************************************************/

void error_fault_handler(volatile uint32_t * hardfault_args,uint32_t err)
{

	app_err_t   g_err_record;
	g_err_record.err_type      = err;

	g_err_record.register_r0  = (uint32_t) hardfault_args[0];
	g_err_record.register_r1  = (uint32_t) hardfault_args[1];
	g_err_record.register_r2  = (uint32_t) hardfault_args[2];
	g_err_record.register_r3  = (uint32_t) hardfault_args[3];
	g_err_record.register_r12 = (uint32_t) hardfault_args[4];
	g_err_record.register_lr  = (uint32_t) hardfault_args[5];
	g_err_record.register_pc  = (uint32_t) hardfault_args[6];
	g_err_record.register_psr = (uint32_t) hardfault_args[7];

	g_err_record.register_bfar = *((volatile unsigned int *)(0xE000ED38));
	g_err_record.register_cfsr = *((volatile unsigned int *)(0xE000ED28));
	g_err_record.register_hfsr = *((volatile unsigned int *)(0xE000ED2C));
	g_err_record.register_dfsr = *((volatile unsigned int *)(0xE000ED30));
	g_err_record.register_afsr = *((volatile unsigned int *)(0xE000ED3C));

	SoftReset();
}



void SoftReset(void)
{
	__set_FAULTMASK(1);      // 关闭所有中端
	__NVIC_SystemReset();		// 复位
}
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
